import axios from 'axios'
import URL from '@/constants/api'
import request from '@/utils/request'
//添加
export function add(data) {
  return request({
    url:`${URL}` + '/op/add',
    method: 'POST',
    data: {
      data
    }
  }).then((res) => {
    return res.data;
  })
}
//删除
export function del(id) {
  return request({
    url:`${URL}` + '/op/del',
    method: 'POST',
    data: {
      id
    }
  }).then((res) => {
    return res.data;
  })
}
//修改
export function update(id) {
  return request({
    url:`${URL}` + '/op/update',
    method: 'POST',
    data: {
      id
    }
  }).then((res) => {
    return res.data;
  })
}
//查通过id
export function getById(id) {
  return request({
    url:`${URL}` + '/op/getById',
    params: {
      id
    }
  }).then((res) => {
    return res.data;
  })
}
//获取所有
export function getAll() {
  return request({
    url:`${URL}` + '/op/getAll',
  }).then((res) => {
    console.log('aswqqasw',res);
    return res.data.data;
  })
}
//登录
export function login(obj) {
  return request({
    url:`${URL}` + '/user/login',
    params: {
      ...obj
    }
  })
    .then((res) => {
      return res.data;
    })
}
//获取左边数据
export function getAsideData() {
  return request({
    url:`${URL}` + '/aside/get',
  }).then((res) => {
    return res.data.data.config;
  })
}
//左边数据
export function addAsideData(config) {
  return request({
    url:`${URL}` + '/aside/add',
    params: {
      config
    }
  }).then((res) => {
    return res.data;
  })
}
